

\newgeometry{left=.1cm,  right=.1cm}
%\newpage
\begin{tikzpicture} [ 
    vh path/.style={to path={|- (\tikztotarget)\tikztonodes}},
    hv path/.style={to path={-| (\tikztotarget)\tikztonodes}},
    hvh path/.style={to path={-- +(-1.5cm, 0) |- (\tikztotarget)\tikztonodes}},
    vhv path/.style={to path={-- +(0, 1.5cm) -| (\tikztotarget)\tikztonodes}},
    stack rect/.style={rectangle, fill=white, minimum width=4cm, minimum height=1cm, draw, rounded corners=1pt}]
    %\node [stack rect](m1){}; 
    %\node [stack rect, xshift=0.2cm, yshift=0.2cm](m2) at (m1.south) {};
    %\node [stack rect, xshift=0.2cm, yshift=0.2cm](m3) at (m2.south) {Job exporter};
    
    %\draw[fill=black!10, draw](0, 0) rectangle (7, 2);
    %\draw[fill=red!10, dashed] (0, 2) rectangle (7, 5);
    %\node[rectangle, xshift=5cm, yshift=1cm, fill=black!50, draw](disk) at (0,0) {SSD/HDD};
    
    \colorlet{prometheusColor}{red!10}

    \node[rectangle, draw, minimum height=2cm, minimum width=1.5cm,fill=white, label={[anchor=north]north:Retrieve}](Retrieve)  {}; 
    \node[rectangle, right= 0.5cm of Retrieve, draw, minimum height=2cm, minimum width=1.5cm, fill=white, label={[anchor=north]north:Storage}](Storage)  {}; 
    \node[rectangle, right= 0.5cm of Storage, draw, minimum height=2cm, minimum width=1.5cm, fill=white, label={[anchor=north]north:PromQL}](PromQL)  {}; 
    %\draw (Retrieve.north west) rectangle (PromQL.south east);
    
    \draw[->] (Retrieve.base) -- (PromQL.base);

 
    \begin{pgfonlayer}{background}
        \node[fit=(Retrieve)(Storage)(PromQL), fill=prometheusColor, draw, dashed, inner sep=20pt, label={[anchor=north]north:Promethues Server}](Promethues Server){};
    \end{pgfonlayer}

    \node[rectangle, below =of PromQL, draw, fill=black!50] (Disk){SSD/HDD};
    \begin{pgfonlayer}{background}
       \coordinate(servercorner) (Promethues Server.south west) -- (Promethues Server.south east) -- +(down:2cm);
       \draw[fill=black!20](Promethues Server.south west) 
         node[label={[anchor=south east, xshift=1cm, yshift=-0.7cm]south east:Node}]
          (NodeServer){} rectangle ($(Promethues Server.south east) + (0, -1.2)$);
    \end{pgfonlayer}

    

    \node[align=center, rectangle split, fill=blue!20, 
     above=2cm of Retrieve,
      rectangle split parts=2, draw](Service Discovery){
         Service Discovery
         \nodepart{second}
         DNS \\ Kubernetes \\ .. \\ Consul 
    };

    

    \node[right=1.2cm of Promethues Server, draw, fill=prometheusColor, minimum width=2.5cm](Web UI){Web UI};
    \node[below=0cm of Web UI, draw, minimum width=2.5cm, fill=prometheusColor](PromDash){PromDash};
    \node[below=0cm of PromDash, draw, minimum width=2.5cm](Grafana){Grafana};
    \node[below=0cm of Grafana, draw, minimum width=2.5cm](Api Clients){Api Clients};
   

    \node[above=2cm of Web UI, draw, minimum height=2cm, fill=prometheusColor](AlertManager){AlertManager};
    \node[above=of AlertManager, draw](Email){Email};
    \node[left=of Email, draw](PageDuty){PageDuty};
    \node[right=of Email, draw](Other){Other};

    \node[above left=of Promethues Server, fill=prometheusColor, draw](PushGateway){PushGateway};
    %\node[left=of Promethues Server, fill=black, minimum height=1cm](Connection){};
   

    \coordinate(BarUpper) at ($(Promethues Server.west) + (-1, 0.5)$);
    \coordinate(BarLower) at ($(BarUpper) + (0, -1.2)$);
    \draw[ultra thick](BarUpper) -- (BarLower);
    \draw[->](Promethues Server) -- ($(BarUpper)!0.5!(BarLower)$);
    \foreach \x/\y in {0.1/1, 0.2/2, 0.3/3, 0.4/4, 0.5/5, 0.6/6}
       \coordinate(ConnectPoint\y) at ($(BarUpper)!\x!(BarLower)$);

    \node [stack rect, below left=3.5cm of NodeServer](m1){}; 
    \node [stack rect, xshift=0.2cm, yshift=0.2cm](m2) at (m1.south) {};
    \node [stack rect, xshift=0.2cm, yshift=0.2cm](m3) at (m2.south) {Job exporter};
    
    
    \node [stack rect, below right=1cm and -4.8cm of m3, xshift=3cm](p1){}; 
    \node [stack rect, xshift=0.2cm, yshift=0.2cm](p2) at (p1.south) {Promethues Server};

    \node [stack rect, above left=1cm of PushGateway](s1){}; 
    \node [stack rect, xshift=0.2cm, yshift=0.2cm](s2) at (s1.south) {Short live job};

    \coordinate(AlertManagerOut) at ($(Promethues Server.east) + (0, 1)$);
    

    %% use quotes library
    \draw[] (Storage.base) edge ["save data"' near start, vh path, <->] (Disk);
    \draw[->] (Retrieve)  to node[fill=white]{find target} (Service Discovery);

    \draw[->](Web UI)  to [ edge node={node[above]{query}}] (Promethues Server);
    \draw[->](PromDash)  to [hvh path](Promethues Server);
    \draw[->](Grafana) to [hvh path](Promethues Server);
    \draw[->](Api Clients)  to [hvh path](Promethues Server);

    \draw[->](AlertManager) to (Email);
    \draw[->](AlertManager)  to [vhv path](PageDuty);
    \draw[->](AlertManager)  to [vhv path](Other);
    \draw[->](AlertManagerOut)  to [hv path] node[above, pos=0.3]{push alerts}(AlertManager);
   % (Retrieve) -> (Connection);
    \draw[->](ConnectPoint1)  to [hv path]node[right, pos=0.7]{pull}(PushGateway);
    %\draw[->](s2)  to [hv path]node[fill=white]{push}(PushGateway);
    \draw[->](ConnectPoint2)  to [hv path] node[left, pos=0.6]{pull}(m1);
    \draw[->](ConnectPoint3)  to [hv path](m2);
    \draw[->](ConnectPoint4)  to [hv path](m3);
    \draw[->](ConnectPoint5)  to [hv path] node[right, pos=0.7]{pull} (p1);
    \draw[->] (ConnectPoint6) to [hv path](p2);

    \graph[edge quotes mid,
     edges={nodes={font=\scriptsize, 
       fill=white, sloped, inner sep=1pt}}]{
        % use graph instance of draw command   
        (s2)  -> [hv path, edge node ={node[fill=white, rotate=90]{push}}](PushGateway);
       
    };

\end{tikzpicture}
\restoregeometry